home *** CD-ROM | disk | FTP | other *** search
- unit dcompfrm;
-
- interface
-
- uses
- SysUtils, Windows, Messages, Classes, Controls, Forms,
- Dialogs, Menus, ShellAPI, StdCtrls, Buttons, ExtCtrls, Grids, ComCtrls;
-
- const
- wm_IconMessage = wm_User;
-
- type
- TDCompForm = class(TForm)
- PopupMenu1: TPopupMenu;
- Options1: TMenuItem;
- About1: TMenuItem;
- N1: TMenuItem;
- Close1: TMenuItem;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Panel1: TPanel;
- KeyListBox: TListBox;
- HeaderControl1: THeaderControl;
- FontList: TComboBox;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure Options1Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure Close1Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FontListChange(Sender: TObject);
- private
- NotifyIcon: TNotifyIconData;
- CharList : TStringList;
- procedure AppOnMessage(var Msg: TMsg; var Handled: Boolean);
- procedure TranslateKeys(First,Second : word;Wnd:THandle);
- procedure InitDefaultList;
- public
- procedure IconTray(var Msg: TMessage); message wm_IconMessage;
- end;
-
- var
- DCompForm: TDCompForm;
- WM_ToggleIcon,
- WM_TranslateKeys : Cardinal;
-
- implementation
-
- procedure EnableHook; stdcall; external 'KeyHook.dll';
- procedure DisableHook; stdcall; external 'KeyHook.dll';
-
- {$R *.DFM}
- {$R DComp.res}
-
- procedure TDCompForm.FormCreate(Sender: TObject);
- begin
- { load the initial icon }
- Icon.Handle := LoadIcon(HInstance, 'LETTERRED');
-
- { fill the NotifyIcon data structure }
- with NotifyIcon do begin
- cbSize := sizeof(NotifyIcon);
- wnd := Handle;
- uID := 1; { icon ID }
- uCallBackMessage := wm_IconMessage;
- hIcon := Icon.Handle;
- szTip := 'DCompose';
- uFlags := nif_Message or nif_Icon or nif_Tip;
- end;
- Shell_NotifyIcon(NIM_ADD, @NotifyIcon);
-
- CharList := TStringList.Create;
- with CharList do begin
- { sort list alphabetically }
- Sorted := true;
- { must set this to accept duplicates; otherwise it seems
- to see the lower and upper case strings as duplicates and
- eliminates lower case }
- Duplicates := dupAccept;
- end;
- InitDefaultList;
-
- Application.OnMessage := AppOnMessage;
- EnableHook;
- end;
-
- procedure TDCompForm.FormDestroy(Sender: TObject);
- begin
- NotifyIcon.uFlags := 0;
- Shell_NotifyIcon (NIM_DELETE, @NotifyIcon);
-
- CharList.Free;
-
- DisableHook;
- end;
-
- procedure TDCompForm.InitDefaultList;
- begin
- with CharList do begin
- Clear;
-
- {0127-0140}
- //
- // Ç
- // ü
- // é
- Add('â'+#9+'f,');
- // ä
- Add('à'+#9+'..');
- Add('å'+#9+'/-');
- Add('ç'+#9+'/=');
- // ê
- Add('ë'+#9+'00');
- Add('è'+#9+'S^');
- // ï
- Add('î'+#9+'OE');
-
- {0141-0150}
- // ì
- // Ä
- // Å
- // É
- // æ
- // Æ
- Add('ô'+#9+'oq');
- Add('ö'+#9+'cq');
- Add('ò'+#9+'bu');
- // û
-
- {0151-0160}
- // ù
- // ÿ
- Add('Ö'+#9+'tm');
- Add('Ü'+#9+'s^');
- // ¢
- Add('£'+#9+'oe');
- // ¥
- // ₧
- Add('ƒ'+#9+'Y"');
-
- {0161-0170}
- Add('í'+#9+'!!');
- Add('ó'+#9+'c|');
- Add('ó'+#9+'c/');
- Add('ú'+#9+'L-');
- Add('ñ'+#9+'xo');
- Add('Ñ'+#9+'Y=');
- Add('ª'+#9+'||');
- Add('º'+#9+'so');
- Add('¿'+#9+'""');
- Add('⌐'+#9+'co');
- Add('¬'+#9+'A_');
-
- {0171-0180}
- Add('½'+#9+'<<');
- Add('¼'+#9+'-,');
- // ¡
- Add('«'+#9+'ro');
- Add('»'+#9+'__');
- Add('░'+#9+'0_');
- Add('▒'+#9+'+-');
- Add('▓'+#9+'2_');
- Add('│'+#9+'3_');
- Add('Æ'+#9+'''''');
-
- {0181-0190}
- Add('╡'+#9+'/U');
- Add('╢'+#9+'P!');
- Add('╖'+#9+'._');
- Add('╕'+#9+',,');
- Add('╣'+#9+'1_');
- Add('║'+#9+'O_');
- Add('╗'+#9+'>>');
- Add('╝'+#9+'14');
- Add('╜'+#9+'12');
- Add('╛'+#9+'34');
-
- {0191-0200}
- Add('┐'+#9+'??');
- Add('└'+#9+'A`');
- Add('┴'+#9+'A''');
- Add('┬'+#9+'A^');
- Add('├'+#9+'A~');
- Add('─'+#9+'A"');
- Add('┼'+#9+'Ao');
- Add('╞'+#9+'AE');
- Add('╟'+#9+'C,');
- Add('╚'+#9+'E`');
-
- {0201-0210}
- Add('╔'+#9+'E''');
- Add('╩'+#9+'E^');
- Add('╦'+#9+'E"');
- Add('╠'+#9+'I`');
- Add('═'+#9+'I''');
- Add('╬'+#9+'I^');
- Add('╧'+#9+'I"');
- Add('╨'+#9+'D-');
- Add('╤'+#9+'N~');
- Add('╥'+#9+'O`');
-
- {0211-0220}
- Add('╙'+#9+'O''');
- Add('╘'+#9+'O^');
- Add('╒'+#9+'O~');
- Add('╓'+#9+'O"');
- Add('╫'+#9+'xx');
- Add('╪'+#9+'O/');
- Add('┘'+#9+'U`');
- Add('┌'+#9+'U''');
- Add('█'+#9+'U^');
- Add('▄'+#9+'U"');
-
- {0221-0230}
- Add('▌'+#9+'Y''');
- Add('▐'+#9+'TH');
- Add('▀'+#9+'ss');
- Add('α'+#9+'a`');
- Add('ß'+#9+'a''');
- Add('Γ'+#9+'a^');
- Add('π'+#9+'a~');
- Add('Σ'+#9+'a"');
- Add('σ'+#9+'ao');
- Add('µ'+#9+'ae');
-
- {0231-0240}
- Add('τ'+#9+'c,');
- Add('Φ'+#9+'e`');
- Add('Θ'+#9+'e''');
- Add('Ω'+#9+'e^');
- Add('δ'+#9+'e"');
- Add('∞'+#9+'i`');
- Add('φ'+#9+'i''');
- Add('ε'+#9+'i^');
- Add('∩'+#9+'i"');
- Add('≡'+#9+'d-');
-
- {0241-0250}
- Add('±'+#9+'n~');
- Add('≥'+#9+'o`');
- Add('≤'+#9+'o''');
- Add('⌠'+#9+'o^');
- Add('⌡'+#9+'o~');
- Add('÷'+#9+'o"');
- Add('≈'+#9+'-:');
- Add('°'+#9+'o/');
- Add('∙'+#9+'u`');
- Add('·'+#9+'u''');
-
- {0251-0255}
- Add('√'+#9+'u^');
- Add('ⁿ'+#9+'u"');
- Add('²'+#9+'y''');
- Add('■'+#9+'th');
- Add(' '+#9+'y"');
- end;
- end;
-
- procedure TDCompForm.IconTray(var Msg: TMessage);
- var
- Pt: TPoint;
- begin
- if Msg.lParam = wm_rbuttondown then begin
- GetCursorPos(Pt);
- SetForegroundWindow(Handle);
- PopupMenu1.Popup(Pt.x, Pt.y);
- end;
- if Msg.lParam = wm_lbuttondblclk then
- Options1Click(self);
- end;
-
- procedure TDCompForm.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
- begin
- if (Msg.hwnd = Handle) or (Msg.hwnd = Application.Handle) then
- if Msg.Message = WM_ToggleIcon then begin
- if Msg.WParam = 1 then begin
- NotifyIcon.hIcon := LoadIcon(HInstance, 'LETTERGREEN');
- end
- else begin
- NotifyIcon.hIcon := LoadIcon(HInstance, 'LETTERRED');
- end;
- Shell_NotifyIcon (NIM_MODIFY, @NotifyIcon);
- Handled := true;
- end
- else if Msg.Message = WM_TranslateKeys then begin
- TranslateKeys(LoWord(Msg.wParam),HiWord(Msg.wParam),Msg.lParam);
- Handled := true;
- end;
- end;
-
- procedure TDCompForm.TranslateKeys(First,Second : word;Wnd:THandle);
- var
- i,AccChar : word;
- begin
- AccChar := 0;
- for i := 0 to pred(CharList.Count) {MaxPairs }do begin
- if (CharList[i][3] = char(First)) and (CharList[i][4] = char(Second)) or
- (CharList[i][4] = char(First)) and (CharList[i][3] = char(Second)) then
- AccChar := ord(CharList[i][1]);
- end;
-
- if AccChar = 0 then begin
- PostMessage(Wnd,WM_Char,First,1);
- PostMessage(Wnd,WM_Char,Second,1);
- MessageBeep(-1);
- end
- else
- PostMessage(Wnd,WM_Char,AccChar,1);
- end;
-
- procedure TDCompForm.Options1Click(Sender: TObject);
- begin
- if not Visible then ShowModal;
- end;
-
- procedure TDCompForm.About1Click(Sender: TObject);
- begin
- MessageDlg('DCompose'#13+'Copyright Warren Kovach 1997',
- mtInformation, [mbOk], 0);
- end;
-
- procedure TDCompForm.Close1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TDCompForm.FormShow(Sender: TObject);
- begin
- KeyListBox.Items := CharList;
- FontList.Items := Screen.Fonts;
- FontList.Text := KeyListBox.Font.Name;
- end;
-
- procedure TDCompForm.FontListChange(Sender: TObject);
- begin
- KeyListBox.Font.Name := FontList.Text;
- end;
-
- initialization
- { must register a unique message ID, both here and in DLL,
- so there is no conflict with other programs }
- WM_ToggleIcon := RegisterWindowMessage('DCompose ToggleIcon');
- WM_TranslateKeys := RegisterWindowMessage('DCompose TranslateKeys');
- end.
-
-
-